package q1184_distanceBetweenBusStops;

public class Solution_1 {
    /*
    计算一个总长度 然后计算一个方向的长度 取 两种方向行驶的最小值即可
     */
    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
        if (start == destination) return 0;
        if (start > destination) return distanceBetweenBusStops(distance, destination, start);
        int sum = 0, ans = 0;
        for (int i : distance) sum += i;

        for (int i = start; i < destination; ++i) ans += distance[i];

        return Math.min(ans, sum - ans);
    }
}
